﻿namespace Dissemination.MVC.Repositories
{
    using System.Linq;
    using System.Collections.Generic;
    using Dissemination.MVC.Models;

    public class SurveyResultRepository : BaseRepository<SurveyResult>
    {
        public SurveyResultRepository()
        {
            EntityName = "SurveyResults";
        }

        public override List<SurveyResult> List()
        {
            return dataContext.SurveyResults.ToList();
        }

        //public Program GetProgramByID(int programID)
        //{
        //    return dataContext.Programs.Include("TargetAreas").FirstOrDefault(p => p.ProgramID == programID);
        //}

        //public SurveyResult GetLastSurveyByProgram(int programID)
        //{
        //    var surveys = (from s in dataContext.Surveys
        //                       where (s.Program.ProgramID == programID)
        //                       orderby s.SurveyOrdinal descending
        //                       select s);

        //    return surveys.FirstOrDefault();
        //}

        public override SurveyResult Get(int id)
        {
            return dataContext.SurveyResults.Include("Survey").Include("TargetArea").FirstOrDefault(sr => sr.SurveyResultsID == id);
        }
    }
}
